#ifndef TCPCLIENT_H
#define TCPCLIENT_H

#include <QWidget>
#include <QTcpSocket>

QT_BEGIN_NAMESPACE
namespace Ui { class TCPClient; }
QT_END_NAMESPACE

#define PORT 8080

class TCPClient : public QWidget
{
    Q_OBJECT

public:
    TCPClient(QWidget *parent = nullptr);
    ~TCPClient();
     void initDataSlot();
     QString getLocalIP();

private slots:
     //自定义槽函数
     void  onConnected() ;
     void  onDisconnected() ;
     void  onSocketStateChange(QAbstractSocket::SocketState socketState) ;
     void  onSocketReadyRead() ; //读取socket传入的数据
     void on_pushButton_connectService_clicked();

     void on_pushButton_sendMsg_clicked();

     void on_pushButton_cleanMsgBox_clicked();

     void on_pushButton_Quit_clicked();

private:
    Ui::TCPClient *ui;

    QTcpSocket * mTcpClient = nullptr;  //socket
    bool misConnectService = false; //判断是否连接了服务器
};
#endif // TCPCLIENT_H
